﻿<?xml version="1.0" encoding="utf-8" ?>
<DbDataRequest connection="$ForumDBConnection$" type="$ForumDBType$" defaultFormatter="bizobj ForumThread(lastPostBy,createdBy))">
  <SqlStatement hasResults="true">
	  SELECT
	  ft.id, ft.title, ft.forumId, ft.totalPosts, ft.dateCreated, ft.threadImageUrl,
	  ft.createdById, ft.createdByName AS createdByuserName,
	  ft.lastPostById, ft.lastPostByName AS lastPostByuserName,
	  f.name AS threadImageUrl
	  FROM ForumThreads ft
	  INNER JOIN ThreadPosts tp ON ft.id=tp.threadId
	  INNER JOIN Forum f ON ft.forumId=f.id
	  WHERE tp.description LIKE '%'+@keyword+'%'
	  OR tp.title LIKE '%'+@keyword+'%'
	  ORDER BY ft.lastPostByName DESC
  </SqlStatement>
  <Param name="keyword" type="varchar" />
</DbDataRequest>
